/* eslint-disable */
// 纯cookie相关 
var CookieUtil = { 
  set: function (name, value, expires, path, domain) { 
  expires = new Date(new Date().getTime() + (((typeof expires == 'undefined') ? 12 * 7200 : expires)) * 1000); 
  var tempcookie = name + '=' + value + 
  ((expires) ? '; expires=' + expires.toGMTString() : '') + 
  ((path) ? '; path=' + path : '; path=/') + ((domain) ? '; domain=' + domain : ''); 
  (tempcookie.length < 4096) ? document.cookie = tempcookie : alert('The cookie is bigger than cookie lagrest'); 
  }, 
  get: function (name) { 
  var xarr = document.cookie.match(new RegExp('(^| )' + name + '=([^;]*)(;|$)')); 
  if (xarr != null) 
  return decodeURIComponent(xarr[2]); 
  return ''; 
  }, 
  getBigIp: function () { 
  var xarr = document.cookie.match(new RegExp('(^| )(BIGip[^;]*)')); 
  if (xarr !== null && xarr.length > 2) 
  return decodeURIComponent(xarr[2]); 
  return ''; 
  }, 
  remove: function (name, path, domain) { 
  if (this.get(name)) { 
  document.cookie = name + '=' + 
  ((path) ? '; path=' + path : '; path=/') + 
  ((domain) ? '; domain=' + domain : '') + 
  ';expires=Thu, 01-Jan-1970 00:00:01 GMT'; 
  } 
  }, 
  clean: function (path, domain) { 
  var keys = document.cookie.match(/[^ =;]+(?=\=)/g); 
  if (keys) { 
  for (var i = keys.length; i--; ) 
  document.cookie = keys[i] + '=' + 
  ((path) ? '; path=' + path : '; path=/') + 
  ((domain) ? '; domain=' + domain : '') + 
  ';expires=Thu, 01-Jan-1970 00:00:01 GMT'; 
  } 
  }, 
  valMatch: function (name, value) { 
  if(!value || typeof value !== 'string') 
  return false;

    return this.get(name) === value;
  },
  setUserName: function (name) {
    if (!name) 
      return

    this.set('username', encodeURI(name));
  },
  getUserName: function () {
    var username = this.get('username');
    return username ? decodeURI(username) : undefined;
  }
};

export default CookieUtil
